<script type="text/javascript">
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
				&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
				&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));

var countOfFields = 1;
var curFieldNameId = 1;
var maxFieldLimit = 10;

function deleteField(a) {
	var contDiv = a.parentNode;
	contDiv.parentNode.removeChild(contDiv);
	countOfFields--;
	return false;
}
function addField() {
	countOfFields++;
	curFieldNameId++;
	var p = document.createElement("p");
	p.innerHTML = '<input name="usrfile[]" type="file" id="fi'+curFieldNameId+'" /> <a onclick="return deleteField(this)" href="#">[X]</a> <a onclick="return addField()" href="#">[+]</a> <a onclick="f_name_l(\'fi'+curFieldNameId+'\')" style="cursor: pointer;">[^]</a>';
	document.getElementById("files").appendChild(p);
	return false;
}
function addFieldL() {
		countOfFields++;
		curFieldNameId++;
		var p = document.createElement("p");
		p.innerHTML = '<input name="linksa['+curFieldNameId+']" type="text" /> <input name="linkst[]" type="text" /><a onclick="return deleteField(this)" href="#">[X]</a> <a onclick="return addFieldL()" href="#">[+]</a>';
		document.getElementById("linkss").appendChild(p);
		return false;
}
function mozz (str1,str2) {
	var ss = document.postfo.text.scrollTop;
	sel1 = document.postfo.text.value.substr(0, document.postfo.text.selectionStart);
	sel2 = document.postfo.text.value.substr(document.postfo.text.selectionEnd);


	sel = document.postfo.text.value.substr(document.postfo.text.selectionStart,
	document.postfo.text.selectionEnd - document.postfo.text.selectionStart);


	var text = document.postfo.text.firstChild;
	document.postfo.text.value = sel1 + str1 + sel + str2 + sel2;


	selPos = str1.length + sel1.length + sel.length + str2.length;
	document.postfo.text.setSelectionRange(sel1.length, selPos);
	document.postfo.text.scrollTop = ss;
}
function insert(str1,str2) {
	if (is_nav) { mozz (str1,str2); }
	frm = document.forms[0].text;
	seltxt = frm.document.selection.createRange();
	seltxt.text = str1+seltxt.text+str2;
	document.forms[0].text.focus();
}
function f_name_l(fileId){
	var formFile = document.getElementById(fileId);
	file_name=formFile.value.replace(/^([^\\\/]*(\\|\/))*/,"");
	if(file_name!="") {
		insert('<a href="files\/'+file_name+'">','<\/a>');
	}
}
</script>
<form method="post" name="postfo" action="" enctype="multipart/form-data">
		<?php echo $ptfup; ?>
		<input type="hidden" name="action" value="<?php echo $_v['action'];?>" /><input type="hidden" name="p" value="<?php echo @$_v['p'];?>" />
		<fieldset>
				<legend>Заголовок</legend>
				<input type="text" name="title" style="width:100%;" value="<?php echo @$post['title'];?>" />
		</fieldset>
		<fieldset>
			<legend>Текст</legend>
			<textarea name="text" id="text" rows="8" cols="4" style="width:100%; height:410px"><?php echo @$post['text'];?></textarea></fieldset>
		<?if(!isset($_v['pg']) && @$_v['action']!="new_pag") { ?>
		<fieldset>
				<legend>Теги, через запятую:</legend>
				<input type="text" name="tags" value="<?php echo @$post['tags']?>" size="50" style="width:100%" />
		</fieldset>
		<fieldset style="width:75%;margin:0 auto;">
			<legend><a href="#" onclick="var open=document.getElementById('additionally'); if(open.style.display=='none')open.style.display='block'; else open.style.display='none';return false"><?php echo $_l['extra_post'];?></a></legend>
			<div id="additionally" style="display:none">
				<p><input name="closep" id="closep" type="checkbox" <?if(@gbuffer($_v['p'],"close")) { echo "checked='checked'"; }?> /> <label for="closep"><?php echo $_l['o_close'];?></label></p>
				<p><input name="nocomm" id="nocomm" type="checkbox" <?if(@gbuffer($_v['p'],"comments")) { echo "checked='checked'"; }?> /> <label for="nocomm"><?php echo $_l['o_commoff'];?></label></p>
				<p><input name="comhidden" id="comhidden" type="checkbox" <?if(@gbuffer($_v['p'],"hidecomm")) { echo "checked='checked'"; }?> /> <label for="comhidden"><?php echo $_l['o_commhide'];?></label></p>
				<p><input name="nomailc" id="nomailc" type="checkbox" <?if(@gbuffer($_v['p'],"nomail")) { echo "checked='checked'"; }?> /> <label for="nomailc"><?php echo $_l['o_nomail'];?></label></p>
				<p><input name="norss" id="norss" type="checkbox" <?if(@gbuffer($_v['p'],"norss")) { echo "checked='checked'"; }?> /> <label for="norss"><?php echo $_l['o_hrss'];?></label></p>
			</div>
		</fieldset>

		<fieldset style="width:75%;margin:0 auto;"><legend><?php echo $_l['extra_post_files']?></legend>
		<div id="files">
			<p><input name="usrfile[]" type="file" id="fi1" /> <a onclick="return addField()" href="#">[+]</a> <a onclick="f_name_l('fi1')" style="cursor: pointer;">[^]</a></p>
		</div>
	</fieldset>
	<?}?>
	<?php echo $ptfdw; ?><br />
	<input name="msubmit" type="submit" id="go" value="<?php echo $_l['c_submit']?>" /><input type="reset" id="cansel" value="<?php echo $_l['c_reset']?>" />
</form>